#ifndef REQUEST_H
#define REQUEST_H

#include <vector>
#include <db_cxx.h>

#include "../../include/config.h"

namespace HappyDB
{
namespace Protocal
{

enum REQUEST_TYPE {
	REQUEST_TYPE_HTTP,
	REQUEST_TYPE_MEMCACHE
};

typedef struct struct_header
{
    std::string name;
    std::string value;
} HEADER;



// COMMAND LIST
//
//   
#define COMMAND_GET			"get"
#define COMMAND_BGET		"bget"
#define COMMAND_ADD			"add"
#define COMMAND_SET			"set"
#define COMMAND_REPLACE		"replace"
#define COMMAND_PREPEND		"prepend"
#define COMMAND_APPEND		"append"
#define COMMAND_CAS			"cas"
#define COMMAND_INCR		"incr"
#define COMMAND_GETS		"gets"
#define COMMAND_DELETE		"delete"
#define COMMAND_OWN			"own"
#define COMMAND_DISOWN		"disown"
#define COMMAND_BG			"bg"
#define COMMAND_STATS		"stats"
#define COMMAND_FLUSH_ALL	"flush_all"
#define COMMAND_VERSION		"version"
#define COMMAND_QUIT		"quit"
#define COMMAND_SLABS		"slabs"
#define COMMAND_REASSIGN	"reassign"
#define COMMAND_VERBOSITY	"verbosity"



// MEMCACHE 
// 
//    <set/add/replace>	<key>	<flags>		<exptime>	<bytes>	\r\n
//    get				<key>	*								\r\n
//    delete			<key>	<time>							\r\n
//    incr				<key>	<value>							\r\n
//    decr				<key>	<value>							\r\n
//    STAT														\r\n
//
// HTTP
//    get				<file>	<http/1.1>						\r\n
//
//
//

typedef struct struct_request
{
	REQUEST_TYPE	request_type;

	// for http
	std::string				http_method;
	std::string				http_uri;
	int						http_version_major;
    int						http_version_minor;
	std::vector<HEADER>		http_headers;


	// for memcached
	std::string				mc_command;
	std::string				mc_key;
	u_int16_t				mc_flag;
	time_t					mc_exptime;
	u_int32_t				mc_bytes;


} REQUEST;


}
}

#endif